
/*
数据库操作:  利用接口(interface)的多态性,提高程序的扩展性
1.打开数据库

2.操作数据库
C  create  R read  U update  D delete

3.关闭数据库

*/
//数据库操作接口
interface CRUD{

	public void add(Object obj);
	public void read(Object obj);
	public void update(Object obj);
	public void delete(Object obj);
}

//JDBC操作数据库
class CheckUserJDBC implements CRUD{

	public void add(Object obj){
		System.out.println("JDBC增加数据");
	}
	public void read(Object obj){
		System.out.println("JDBC读取数据");
	}
	public void update(Object obj){
		System.out.println("JDBC更新数据");
	}
	public void delete(Object obj){
		System.out.println("JDBC删除数据");
	}
}

//Hibernate操作数据库
class CheckUserHib implements CRUD{

	public void add(Object obj){
		System.out.println("Hib增加数据");
	}
	public void read(Object obj){
		System.out.println("Hib读取数据");
	}
	public void update(Object obj){
		System.out.println("Hib更新数据");
	}
	public void delete(Object obj){
		System.out.println("Hib删除数据");
	}
}



class DataCheck{
	public static void main(String[] args) {
		//CheckUserJDBC c = new CheckUserJDBC();
		CheckUserHib c = new CheckUserHib();

		c.add(new Object());
		c.read(new Object());
		c.update(new Object());
		c.delete(new Object());
	}
}




